package mapevents;

import gameengine.map.Map;
import gameengine.map.unit.Unit;

public final class MapMoveEvent extends AbstractMapEvent {

    private final transient AbstractMapEvent startEvent;
    private final transient AbstractMapEvent targetEvent;

    public MapMoveEvent(final AbstractMapEvent start, final AbstractMapEvent target) {
        super();
        startEvent = start;
        targetEvent = target;
    }

    @Override
    public MAPEVENTTYPE getType() {
        return MAPEVENTTYPE.MOVE;
    }

    @Override
    public int getXStart() {
        return startEvent.getXStart();
    }

    @Override
    public int getYStart() {
        return startEvent.getYStart();
    }

    @Override
    public int getXTarget() {
        return targetEvent.getXStart();
    }

    @Override
    public int getYTarget() {
        return targetEvent.getYStart();
    }

    @Override
    public Unit getUnit() {
        return startEvent.getUnit();
    }

    @Override
    public Unit getAttacker() {
        return null;
    }

    @Override
    public String toString() {
        final StringBuilder builder = new StringBuilder();

        builder.append("move ");
        builder.append(startEvent.getXStart()).append(" ");
        builder.append(startEvent.getYStart()).append(" ");
        builder.append(targetEvent.getXStart()).append(" ");
        builder.append(targetEvent.getYStart()).append(" ");

        return builder.toString();
    }

    @Override
    public AbstractMapEvent newMapEvent(final int xClick, final int yClick, final boolean leftClick, final Map map, final int party) {
        return getMapEvent(xClick, yClick, leftClick, map, party);
    }
}
